#ifndef TRIFRACTAL_H
#define TRIFRACTAL_H

#include "effects.h"

// Globals
const int background_tris = 64;
const float background_update_interval = 1.0f / 15.0f;

/*==============================================================================
                              Trifractal effect class
==============================================================================*/

class TriFractal : public Effect
{
public:
	TriFractal(Video* video, Sound* sound);
	~TriFractal();

	// Draw effect on screen
	virtual void Render();

private:
	// Describes a triangle
	struct EqlTri
	{
		Vector2 c;
		float r, phi;
		Color color;
	};

	// Draws a triangle
	void DrawEqlTri(const EqlTri& tri);

	// Time, when background was updates last time
	float background_last_update;
	// Background triangles
	EqlTri background[background_tris];

	// Draw background
	void RenderBackground();

	// Draw fractal - main part of the effect
	void DrawFractal(const Vector2& pos, float distance, float distance_ratio, 
        float size, float size_ratio, float rotation, float delta_rotation, int depth);
};

#endif